package com.loveshare.backend.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.loveshare.backend.entity.AdminUser;

@Repository
public class AdminUserDaoImpl implements AdminUserDao{
	
	@Autowired
	JdbcTemplate jdbcTemplate;
	
	public int checkAdminUser(AdminUser adminUser) {
		String sql="SELECT id FROM AdminUser WHERE userName=? and password=?";
		Integer num= 0;
		try {  
			num= jdbcTemplate.queryForObject(sql, new Object[]{adminUser.getUserName(),adminUser.getPassword()},Integer.class);
		} catch (EmptyResultDataAccessException e) {  
		    return 0;  
		}  
		return num;
	}

}
